

(function (window, $, ko, app, undefined) {
    app.flatArray_2_nestedArray = function(array, parentID){
        var ret = [];
        var parent_id = parentID || 0;
        for (var i=0, len=array.length; i<len; i++){
            if (array[i].parent_id==parent_id){
               array[i].children = app.flatArray_2_nestedArray(array, array[i].id);
               ret.push(array[i]);
            };
        };
        return ret;
    };
    
    app.getDatafromServer = function(obj){
            return $.ajax({
                    type:   obj.type    || "GET",
                    url:    obj.url     || "",
                    cache:  obj.cache   || false,
                    timeout:obj.timeout || 20000,
                });
    };
    $(document).ready(function(){
        
    });
    
}(window, jQuery, ko, window.app = window.app || {}));
